/*
 * Copyright (C), 2014-2015, 联创车盟汽车服务有限公司
 * FileName: SingleOrderService.java
 * Author:   Administrator
 * Date:     2015年2月3日 下午4:37:55
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>    <time>    <version>    <desc>
 * 修改人姓名        修改时间        版本号        描述
 */
package com.linkage.service.order;

import java.util.*;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.linkage.pojo.order.SingleOrder;
import com.linkage.repository.order.SingleOrderRepository;

/**
 * 〈一句话功能简述〉<br> 
 * 〈功能详细描述〉
 *
 * @author Administrator
 *
 */
@Service
public class SingleOrderService {
    @Autowired
    private SingleOrderRepository singleOrderRepository;
    
    public List<SingleOrder> listAll(){
        return singleOrderRepository.listAll();
    }

    public Map<String,Object> getSingleOrderById(Integer singleOrderId){
        return this.singleOrderRepository.getSingleOrderById(singleOrderId);
    }
    
    public List<Map<String,Object>> getSingleOrderByUserId(Integer userId){
        return this.singleOrderRepository.getSingleOrderByUserId(userId);
    }

    public void setSingleOrderState(Integer status, Integer singleOrderId){
        this.singleOrderRepository.setSingleOrderState(status, singleOrderId);
    }
    
    
    public String generatePreference(Integer userId, Integer bookId){
        Date date=new Date();
        
        Integer day=date.getDay(); 
        Integer month=date.getMonth();
        Integer year=date.getYear()+1900;
        
        String preference=year.toString()+month.toString()+day.toString()+userId.toString()+bookId.toString();
        
        return preference;
        
   }

   public List<SingleOrder> selectSingleOrderByUserId(Integer userId){
       
       return this.singleOrderRepository.selectSingleOrderByUserId(userId);
       
   }
   
   public void saveSingleOrder(SingleOrder singleOrder){
       
       this.singleOrderRepository.saveSingleOrder(singleOrder);
       
   }
}
